﻿Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Collections
Imports System.Data

Public Class CurrentInfo
    ''' <summary>
    ''' 员工姓名
    ''' </summary>
    Public Shared LoginName As String = String.Empty
    ''' <summary>
    ''' 员工卡号
    ''' </summary>
    Public Shared LoginCardNO As String = String.Empty
    ''' <summary>
    ''' 登录密码
    ''' </summary>
    Public Shared LogPassWord As String = String.Empty
    ''' <summary>
    ''' 员工唯一标识
    ''' </summary>
    Public Shared LoginID As String = String.Empty
    ''' <summary>
    ''' 员工所属车间
    ''' </summary>
    Public Shared LoginWorkDeptID As String = String.Empty
    ''' <summary>
    ''' 员工所属车间名称
    ''' </summary>
    Public Shared LoginWorkDeptName As String = String.Empty
    ''' <summary>
    ''' 员工所属班组名称
    ''' </summary>
    Public Shared LoginWorkGroupName As String = String.Empty
    ''' <summary>
    ''' 员工所属班组编号
    ''' </summary>
    Public Shared LoginWorkGroupID As String = String.Empty
    ''' <summary>
    ''' 基础数据班组信息
    ''' </summary>
    Public Shared WorkGroupTable As DataTable = Nothing
    ''' <summary>
    ''' 基础数据工序信息
    ''' </summary>
    Public Shared SpecTable As DataTable = Nothing
    ''' <summary>
    ''' 基础数据产品信息
    ''' </summary>
    Public Shared ProductTable As DataTable = Nothing
    ''' <summary>
    ''' 基础数据资源信息
    ''' </summary>
    Public Shared ResourceTable As DataTable = Nothing
    Public Shared EmployeeTable As DataTable = Nothing
    ''' <summary>
    ''' 基础数据车间信息
    ''' </summary>
    Public Shared FactoryTable As DataTable = Nothing
    ''' <summary>
    ''' 基础数据供应商信息
    ''' </summary>
    Public Shared VendorTable As DataTable = Nothing
    ''' <summary>
    ''' 登录用户所属角色列表
    ''' </summary>
    Public Shared UserRoleList As New List(Of String)()
    '''// <summary>
    '''// 控件字典集
    '''// </summary>
    'public static DataTable DictoryControlTable = new DataTable();
    '''// <summary>
    '''// 表格字典集
    '''// </summary>
    'public static DataTable DictoryGridTable = new DataTable();
    '''// <summary>
    '''// 工种
    '''// </summary>
    'public static DataTable OperationTable = new DataTable();
    '''// <summary>
    '''// 工种对应员工列表
    '''// </summary>
    'public static DataTable OperatioEmployeeTable = new DataTable();
    Public Shared ResourceGroupTable As New DataTable()
    ''' <summary>
    ''' 查询设计器窗口关键字信息
    ''' </summary>
    Public Shared QueryKey As New DataTable()
    ''' <summary>
    ''' 资源组名称
    ''' </summary>
    Public Shared ResourceGroupName As String = ""
    ''' <summary>
    ''' 资源组ID
    ''' </summary>
    Public Shared ResourceGroupID As String = ""
    Public Shared Function ReplaceProductNameForContainer(ByVal strProductName As String, ByVal strResource As String) As String
        Return strResource.Replace(strProductName + "/", " ").Trim()
    End Function

    ''' <summary>
    ''' 显示批次去掉零件图号
    ''' </summary>
    ''' <param name="strResource"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function BJ_ReplaceForContainer(ByVal strResource As String) As String
        Dim strArray As String() = strResource.Split("/"c)
        If strArray.Length >= 2 Then
            Return strArray(strArray.Length - 1)
            'Return strArray(1)
        Else
            Return strResource
        End If
    End Function
    Public Shared Function ReplaceProductNameForSpec(ByVal strProductName As String, ByVal strResource As String) As String
        Dim strArray As String() = strResource.Split("-"c)
        Dim intLength As Integer = strArray.Length
        Dim i As Integer = 0
        Dim strTmp As String = ""
        If intLength >= 3 Then
            strTmp = strArray(intLength - 2) + "-" + strArray(intLength - 1)
        Else
            strTmp = strResource
        End If
        Return strTmp
    End Function
    Public Shared Function ReplaceProductNameForSpec(ByVal strResource As String) As String
        Dim strArray As String() = strResource.Split("-"c)
        Dim intLength As Integer = strArray.Length
        Dim i As Integer = 0
        Dim strTmp As String = ""
        If intLength >= 3 Then
            strTmp = strArray(intLength - 2) + "-" + strArray(intLength - 1)
        Else
            strTmp = strResource
        End If
        Return strTmp
    End Function

    Public Shared Function ReplaceProductNameForContainer(ByVal strContainerName As String) As String
        Dim strDispContainerName As String = ""
        Dim strArray As String() = strContainerName.Split("/")
        If (strArray.Length >= 2) Then
            strDispContainerName = strArray(1)
        Else
            strDispContainerName = strContainerName
        End If
        Return strDispContainerName
    End Function


    ''' <summary>
    ''' 当前程序版本号
    ''' </summary>
    Public Shared ClientVersion As String = String.Empty
#Region "将DataRow[]转换为DataTable 该方法由张辉于2014年04月24日整理到全局类"
    Public Shared Function ToDataTable(ByVal rows As DataRow()) As DataTable
        If rows Is Nothing OrElse rows.Length = 0 Then
            Return Nothing
        End If
        Dim tmp As DataTable = rows(0).Table.Clone()
        '复制DataRow的表结构
        For Each row As DataRow In rows
            '将DataRow添加到DataTable中
            tmp.ImportRow(row)
        Next
        Return tmp
    End Function
#End Region

    ''' <summary>
    ''' 显示批次去掉零件图号
    ''' </summary>
    ''' <param name="strResource"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function BJ_ReplaceForChildrenContainer(ByVal strResource As String) As String
        Dim result = ""
        Dim strArray As String() = strResource.Split("/")
        If strArray.Length >= 2 Then
            Dim arr As String() = strArray(1).Split("-")
            If arr.Length = 3 Then
                result = arr(2)
            End If

        End If
        Return result
    End Function

End Class
